<pre id="iframe1-srcdoc" style="display: none;">
&lt;script&gt;
try {
  top.navigator;
  console.log('FAIL');
} catch (e) {
  console.log("iframe1: " + e.toString());
}
this.x = 7;
window.name = 'navigator';
try {
  top.navigator;
  console.log('FAIL');
} catch (e) {
  console.log("iframe1: " + e.toString());
}
&lt;/script&gt;
</pre>

<pre id="iframe2-srcdoc" style="display: none;">
&lt;script&gt;
try {
  top.navigator;
  console.log('FAIL');
} catch (e) {
  console.log("iframe2: " + e.toString());
}
&lt;/script&gt;
</pre>

<script>
if (window.testRunner)
    testRunner.dumpAsText();

function createIFrame(srcdoc) {
  var iframe = document.createElement('iframe');
  iframe.sandbox = "allow-scripts";
  iframe.srcdoc = srcdoc;
  return iframe;
}

var iframe1 = createIFrame(
    document.getElementById('iframe1-srcdoc').textContent);
var iframe2 = createIFrame(
    document.getElementById('iframe2-srcdoc').textContent);

iframe1.addEventListener('load', () => {
  document.body.appendChild(iframe2);
}, false);
document.body.appendChild(iframe1);
</script>
